package Frames_juego.efectos;

//SplashScreen.java
//A simple application to show a title screen in the center of the screen
//for the amount of time given in the constructor.  This class includes
//a sample main() method to test the splash screen, but it's meant for use
//with other applications.
//

import java.awt.*;

import javax.swing.*;




/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
@SuppressWarnings("serial")
public class SplashScreen extends JWindow {
	private int duration;
	private JLabel jLabelTitle;

	public SplashScreen(int d) 
	{
		duration = d;
	}

	// A simple little method to show a title screen in the center
	// of the screen for the amount of time given in the constructor
	public void showSplash() {
		this.setLocationByPlatform(true);
		 JPanel content = (JPanel)getContentPane();
		 content.setBackground(new java.awt.Color(191,191,191));
		 content.setLayout(null);
		 JLabel label = new JLabel();
		 Toolkit.getDefaultToolkit().getScreenSize();
		 this.setSize(700, 500);
		 centrar_pantalla();
		
		 // Build the splash screen

		 {
			 jLabelTitle = new JLabel();
			 content.add(jLabelTitle);
			 jLabelTitle.setIcon(new ImageIcon(getClass().getClassLoader().getResource("Imagenes/splash/invasion.gif")));
			 jLabelTitle.setBounds(180, 10, 500, 70);
		 }
		
		 content.add(label, BorderLayout.WEST);
		 label.setIcon(new ImageIcon(getClass().getClassLoader().getResource("Imagenes/splash/principal.jpg")));
		 label.setBounds(0, 0, 700, 500);


		 // Display it
		 setVisible(true);
		
		 // Wait a little while, maybe while loading resources
		 try { Thread.sleep(duration); } catch (Exception e) {}
		
		 setVisible(false);
		
	}
	
	public void centrar_pantalla()
	{
		Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
		int y = (int) dim.getHeight()/2;
		int x = (int) dim.getWidth()/2;
		y-=this.getHeight()/2;
		x-=this.getWidth()/2;
		
		this.setLocation(x,y);
	}

	public void showSplashAndExit() {
		showSplash();
		
	}

}